CSE 373: Data
Structures and Algorithms
Winter 2000
Assignment 1 Chapter 2 Due
January 7, 2000
Please include your name and student id # on what you turn
in.
- Exercise
2.6 (a) [exercise 2.7 (a) in the C++ book]
- Exercise
2.8 [exercise 2.9 in the C++ book]
- Exercise
2.12 [exercise 2.17 (a) in the C++
book]
- Exercise
2.16 [exercise 2.23 in the C++ book]
- Exercise
2.18 [exercise 2.25 in the C++ book]
- Various
programming environments provide a function for copying memory between two
locations (e.g., strncpy(src, dst, size) in C). However, these routines do not always take into account the
situation where src and dst overlap.
For example, if src = 1000 and dst = 1050 and size = 100 the last
half of src overlaps with the first half of dst. If src and dst are reversed in the above example the overlap
is just opposite. Provide a convincing
argument why the following code fragment for copying strings is buggy and
then give the corrected code fragment (assume that dst and src are
declared “char *”.)
for (i=0; i < size; i
+= 1) { dst[i] = src[i]);}
- [Not
graded] How much time did you spend on this homework assignment? On a scale from 1 to 10 (1 being way
too easy, 5 being just about right, and 10 being way too hard) how would
you rate this for a weekly homework assignment?